package com.hzlj.position.config.common.enums;

import com.fz.common.base.exception.PubError;
import com.fz.common.base.exception.PubException;
import lombok.Getter;

/**
 * @author fanzhuo
 */

@Getter
public enum OperatorActivationStatus {
    INIT("0", "未开通"),
    ACTIVATION("1", "已开通"),
    DEACTIVATE("2", "已取消"),
    ;

    private final String code;
    private final String text;

    OperatorActivationStatus(String code, String text) {
        this.code = code;
        this.text = text;
    }

    public static OperatorActivationStatus of(String value) {
        for (OperatorActivationStatus checkTypeEnum : values()) {
            if (checkTypeEnum.getCode().equals(value)) {
                return checkTypeEnum;
            }
        }
        throw new PubException(PubError.PARAM_EMPTY_ERROR);
    }

    public static boolean isInit(String code) {
        return INIT.equals(of(code));
    }

    public static boolean isActivation(String code) {
        return ACTIVATION.equals(of(code));
    }

    public static boolean isDeactivate(String code) {
        return DEACTIVATE.equals(of(code));
    }

    public static boolean canActivation(String code) {
        OperatorActivationStatus status = of(code);
        return status.equals(INIT) || status.equals(DEACTIVATE);
    }

    public static boolean canDeactivate(String code) {
        OperatorActivationStatus status = of(code);
        return status.equals(ACTIVATION);
    }

}
